﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="cert.aspx.cs" Inherits="search_cert" %>

	<!-- Bootstrap -->
	<link href="/Public/Home_v2/css/bootstrap.min.css" rel="stylesheet">
	<link href="/Public/Home_v2/css/bootstrap-theme.css" rel="stylesheet">
	<link rel="stylesheet" href="/Public/Home/css/colorbox.css" />
	<link href="/Public/Home_v2/css/toastr.min.css" rel="stylesheet">
	<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
	<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
	<!--[if lt IE 9]>
	<script src="//cdn.bootcss.com/html5shiv/3.7.2/html5shiv.min.js"></script>
	<script src="//cdn.bootcss.com/respond.js/1.4.2/respond.min.js"></script>
	<![endif]-->

	<div class="Member_content">
		<div class="col-sm-12">
			<div class="container" style="margin-top:20px;">
				<!-- Nav tabs -->
	
				<div class="panel" style="background-color:#d4dfe8;border:none;border-radius:0;">
					<div class="panel-body">
						<div class="tab-content nav-search-tabs-content">
							<div role="tabpanel" class="tab-pane active" id="search-ct">
								<form class="form-inline search-form" action="/search/cert.aspx">
									<div class="form-group">
										<div class="input-group" style="width:255px;">
											<span class="input-group-addon" id="basic-addon1">单据编号：</span>
											<input type="text" class="form-control" name="d" value="<%=djbh %>" placeholder="出库单据号" aria-describedby="basic-addon1">
										</div>
									</div>
									<div class="form-group">
										<div class="input-group" style="width:335px;">
											<span class="input-group-addon" id="basic-addon3">其他信息：</span>
											<input type="text" class="form-control" name="k" value="<%=keyword %>" placeholder="药品编号/名称/拼音码/批准文号" aria-describedby="basic-addon3">
										</div>
									</div>
                                    <div class="form-group">
										<div class="input-group" style="width:335px;">
											<span class="input-group-addon" id="basic-addon2">类别：</span>
                                            <select name='typeid' class="form-control">
                                                <option value="quanbu" >全部</option>
                                                <option value="zc" <%if (typeid=="zc"){%>selected<%} %> >注册证</option>
                                                <option value="pj" <%if (typeid=="pj"){%>selected<%} %> >批件</option>
                                                <option value="bz" <%if (typeid=="bz"){%>selected<%} %> >包装</option>
                                                <option value="sm" <%if (typeid=="sm"){%>selected<%} %> >说明书</option>
                                                <option value="sf" <%if (typeid=="sf"){%>selected<%} %> >标准</option>
                                                <option value="pf" <%if (typeid=="pf"){%>selected<%} %> >物价</option>
                                                <option value="rf" <%if (typeid=="rf"){%>selected<%} %> >省检</option>                            
                                            </select>											
										</div>
									</div>
									<div class="form-group">
										<button type="submit" class="btn-search">查询</button>
									</div>
								</form>
							</div>							
						</div>
						<div class="panel" style="border:none;border-radius:0;margin-top:15px;background:none;">
							<div class="panel-body searxh-content" style="padding:0;border:none;border-radius:0;">								
									<div id="myTabContent" class="tab-content" style="padding:30px;background-color:#ffffff;">
										<div role="tabpanel" class="tab-pane active" id="42791" aria-labelledby="42791-tab">
                                            <form id="form1" runat="server">
                                                <asp:literal ID="ResultDeBug" runat="server"></asp:literal>
                                                <asp:literal ID="result" runat="server"></asp:literal>
                                                <asp:literal ID="Literal1" runat="server"></asp:literal>
                                            </form>										
                                </div>
                            </div>
						</div>
					</div>
				</div>
			</div>
                <%=Footer %>
		</div>
	</div>
</div>
<div class="container">
	<iframe src="about:blank" id="download_iframe" style="display:none;"></iframe>
</div>
<!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
<script src="/Public/Home/js/jquery.js" type=text/javascript></script>
<!-- Include all compiled plugins (below), or include individual files as needed -->
<script src="/Public/Home_v2/js/bootstrap.min.js"></script>
<script type="text/javascript" src="/Public/Home_v2/js/toastr.min.js"></script>
<script src="/Public/Home/js/jquery.colorbox.js" type="text/javascript"></script>
<script src="/Public/Home/js/jqueryui.js" type="text/javascript"></script>
<script src="/Public/Home/js/jquery.mousewheel.min.js" type="text/javascript"></script>
<script src="/Public/Home/js/jquery.iviewer.min.js" type="text/javascript"></script>
<script src="/Public/Home/Lodop6.198/LodopFuncs.js" type="text/javascript"></script>
<script type="text/javascript" src="/Public/Home/lhgdialog/lhgdialog.js?skin=discuz"></script>
<script type="text/javascript">
    $(document).ready(function () {
        if (!('placeholder' in document.createElement('input'))) {
            $('input[placeholder],textarea[placeholder]').each(function () {
                var that = $(this),
					text = that.attr('placeholder');
                if (that.val() === "") {
                    that.val(text).addClass('placeholder');
                }
                that.focus(function () {
                    if (that.val() === text) {
                        that.val("").removeClass('placeholder');
                    }
                })
					.blur(function () {
					    if (that.val() === "") {
					        that.val(text).addClass('placeholder');
					    }
					})
					.closest('form').submit(function () {
					    if (that.val() === text) {
					        that.val('');
					    }
					});
            });
        }
        $('#myTabDrop1-contents').on('click', 'a', function () {
            $('#myTabDrop1').html($(this).text() + ' <span class="caret"></span>');
            return true;
        });
        $('#myTabs').on('click', 'li.level', function () {
            $('#myTabDrop1').html('更多公司查询结果 <span class="caret"></span>');
            return true;
        });
        $('.preview').colorbox({ width: '80%', height: '100%', current: "{current}/{total}" });
        $(document).bind('cbox_complete', function () {
            var $element = $.colorbox.element();
            var image_url = $("#cboxLoadedContent img").attr('src');
            $("#cboxLoadedContent img").remove();
            $("#cboxLoadedContent").iviewer({ src: image_url });
        });
        $(".check_all").click(function () {
            $(this).closest('table').find(".check_all").prop("checked", $(this).prop("checked"));
            $(this).closest('table').find(":checkbox[name='ids']").prop("checked", $(this).prop("checked"));
        });
        $('.search-form').on('submit', function () {
            $form = $(this);

            var valid = false;
            $("[type='text']", $form).each(function () {
                if ($.trim($(this).val()) != "") {
                    valid = true;
                    return false;
                }
            });
            if (valid === false) {
                toastr.error(false, '请输入查询条件', {
                    timeOut: 1000,
                    onHidden: function () {
                        $("input[name='d']", $form).focus();
                    }
                });
                return false;
            }

            var d = $("input[name='d']", $form).val();
            var dlength = $.trim(d).length;
            if (dlength > 0) {
                if (dlength < 4) {
                    toastr.error(false, '单据号至少输入4位才能查询', {
                        timeOut: 1000,
                        onHidden: function () {
                            $("input[name='d']", $form).focus();
                        }
                    });
                    return false;
                }
            } else {
                if ($form.attr('name') == 'search-batch' || $form.attr('name') == 'search-invoice') {
                    var n = $("input[name='n']", $form).val();
                    var nlength = $.trim(n).length;
                    if (nlength > 0 && nlength < 4) {
                        toastr.error(false, '批号至少输入4位才能查询', {
                            timeOut: 1000,
                            onHidden: function () {
                                $("input[name='n']", $form).focus();
                            }
                        });
                        return false;
                    }
                }

                var k = $("input[name='k']", $form).val();
                var klength = $.trim(k).length;
                if (klength > 0 && klength < 2) {
                    toastr.error(false, '关键字至少输入2位才能查询', {
                        timeOut: 1000,
                        onHidden: function () {
                            $("input[name='k']", $form).focus();
                        }
                    });
                    return false;
                }

            }
            //			if($form.attr('name') == 'search-invoice'){
            //				var is_supplier = '//';
            //				var username = '//';
            //				if(is_supplier != '1' && username.indexOf("医院") == -1 ){
            //					toastr.error(false, '只有医院才能查询发票', {
            //						timeOut: 1000
            //					});
            //					return false;
            //				}
            //			}
            return true;
        });

        $('.operation').on('click', function () {
            var title = '';
            var ids = [];
            var idsx = [];
            var data_optio = $(this).attr('data-optio');
            var opt = $(this).attr('data-opt');
            var act = '1';
            var business_id = $('#myTabContent').find('.tab-pane.active').attr('id');
            if ($(this).attr('data-id')) {
                var title = $(this).closest('tr').find('td.title').text();
                ids.push($(this).attr('data-id'));
            } else {
                $(this).closest('table').find(":checkbox[name='ids']").each(function () {
                    if ($(this).prop("checked")) {
                        if (title == '') {
                            title = $(this).closest('tr').find('td.title').text();
                        }
                        ids.push($(this).val());
                    }
                });
            }
            if (data_optio) {
                $(".dayin").each(function () {
                    idsx.push($(this).val());
                });
            }
            if (ids.length == 0) {
                $.dialog.alert('请选择要进行操作的数据');
                return false;
            }
            $.dialog.tips('数据加载中...', 1000, 'loading.gif');
            $.ajax({
                url: '/search/cert.ashx',
                type: "post",
                data: { act: act, opt: opt, business_id: business_id, ids: ids, idsx: idsx, data_optio: data_optio },
                dataType: 'json',
                success: function (data) {
                    if (data.code == 1) {
                        $.dialog.tips('数据加载中...', 1, 'loading.gif', function () {
                            if (opt == 'print') {
                                if (data.type == 1) {
                                    var _img = new Array();
                                    var printer = getLodop();
                                    $.each(data.url, function (i) {
                                        _img.push(this);
                                        printer.ADD_PRINT_IMAGE(0, 0, '100%', '100%', "<img width='1240' height='1754' src='" + this + "' />");
                                        printer.SET_PRINT_STYLEA(0, "Stretch", 2);
                                        //水印效果begin----
                                        if (i == 0 && title != '') {
                                            printer.ADD_PRINT_TEXT(10, 10, '100%', '100%', title);
                                            printer.SET_PRINT_STYLEA(0, "FontSize", 12);
                                        }
                                        printer.ADD_PRINT_TEXT(0, 0, 780, 10, "<%=djbh %>");
                                        //水印效果end-----
                                        printer.NewPage();
                                    });
                                    printer.preview();
                                    $.ajax({
                                        url: '/search/cert.ashx',
                                        type: 'post',
                                        data: { img: _img, opt: 'dalete_img' },
                                        dataType: 'json',
                                        success: function (data) {

                                        }
                                    });
                                } else {
                                    var printer = getLodop();
                                    $.each(data.url, function (i) {
                                        printer.ADD_PRINT_IMAGE(0, 0, '100%', '100%', "<img width='1240' height='1754' src='" + this + "' />");
                                        printer.SET_PRINT_STYLEA(0, "Stretch", 2);
                                        //水印效果begin----
                                        if (i == 0 && title != '') {
                                            printer.ADD_PRINT_TEXT(10, 10, '100%', '100%', title);
                                            printer.SET_PRINT_STYLEA(0, "FontSize", 12);
                                        }
                                        printer.ADD_PRINT_TEXT(0, 0, 780, 10, "<%=djbh %>");
                                        //水印效果end-----
                                        printer.NewPage();
                                    });
                                    printer.preview();
                                }
                            } else if (opt == 'download') {
                                $('#download_iframe').attr('src', data.url);
                            }
                        });
                    } else {
                        $.dialog.tips(data.msg ? data.msg : '抱歉，系统错误，请稍后再试！', 2, 'error.gif');
                    }
                },
                error: function () {
                    $.dialog.tips('抱歉，系统错误，请稍后再试！', 2, 'error.gif');
                }
            });
            return false;
        });
        $('.tixing').on('click', function () {
            var $obj = $(this);
            var data_optio = $obj.attr('data-optio');
            var id = $obj.attr('data-id');
            if ($obj.text() == '已提醒') {
                return false;
            }
            var business_id = $('#myTabContent').find('.tab-pane.active').attr('id');
            var msg = '<div style="line-height:25px;font-size:14px;color:#F00;">为了能够更快捷的上传报告，请确认你要提醒的信息是否正确。<br />药品名称：' + $obj.closest('tr').find('td.drug_name').text();
            msg += '<br />药品规格：' + $obj.closest('tr').find('td.drug_rule').text();
            msg += '<br />药品单位：' + $obj.closest('tr').find('td.drug_point').text();
            msg += '<br />生产厂家：' + $obj.closest('tr').find('td.drug_changjia').text();
            if ($obj.closest('tr').find('td.drug_batch_number').length > 0) {
                msg += '<br />药品批号：' + $obj.closest('tr').find('td.drug_batch_number').text();
            }
            msg += '</div>';

            $.dialog.confirm(msg, function () {
                $.ajax({
                    url: '/search/reminder.ashx',
                    type: 'post',
                    data: { id: id, business_id: business_id, type: '1', data_optio: data_optio },
                    dataType: 'json',
                    success: function (data) {
                        if (data.code == 1) {
                            $obj.text('已提醒');
                        } else {
                            $.dialog.tips(data.msg ? data.msg : '抱歉，系统错误，请稍后再试！', 2, 'error.gif');
                        }
                    },
                    error: function () {
                        $.dialog.tips('抱歉，系统错误，请稍后再试！', 2, 'error.gif');
                    }
                });
            });
            return false;
        });
        $('.logout').on('click', function () {
            var href = $(this).attr('href');
            $.dialog.confirm('您确定要退出登录吗？', function () {
                window.location.href = href;
            });
            return false;
        });

        $("#aFloatTools_Show").click(function () {
            $('#divFloatToolsView').animate({ width: 'show', opacity: 'show' }, 100, function () { $('#divFloatToolsView').show(); });
            $('#aFloatTools_Show').hide();
            $('#aFloatTools_Hide').show();
        });
        $("#aFloatTools_Hide").click(function () {
            $('#divFloatToolsView').animate({ width: 'hide', opacity: 'hide' }, 100, function () { $('#divFloatToolsView').hide(); });
            $('#aFloatTools_Show').show();
            $('#aFloatTools_Hide').hide();
        });
    });
</script>
</body>
</html>